// JavaScript Document
var home = (function() {
	function init(){
		menuHome();
		scrollingHome();
		createScroll('.search-product-scroll');
		createScroll('.info-cart-scroll');
		chooseSubimages();
	}
	var toggle = 1;
	function menuHome(){
	  $('.nav-menu').click(function(){
	  	var arrow = $('.commonPage .box-left .bg-yl span');
	  	if(toggle == 1){
	  		$('.navigation-container').css({'display':'block'});
	  		arrow.css({'display':'block'});
	  		toggle = 2;	
	  	}else{
	  		$('.navigation-container').css({'display':'none'});
	  		arrow.css({'display':'none'});
	  		toggle = 1;	
	  	}
	  	 return false;
	  });
	  
	   $('.nav-menu').hover(function(){
	   		$('.navigation-container').css({'display':'block'});
	   },function(){
	   		$('.navigation-container').css({'display':'none'});
	   });
	  
	}
	
	function chooseSubimages(){
		$('.box-detail .detail-top .big-image ul.sub-images li a').hover(function(){
			var img = $(this).find('img').attr('src');
			$('.box-detail .detail-top .big-image .main-image a.zoomple').attr('href',img);
			$('.box-detail .detail-top .big-image .main-image a.zoomple').attr('rel',img);
			$('.box-detail .detail-top .big-image .main-image a.zoomple img').attr('src',img);
		});
	}
	
	function createScroll(clsDiv){
		$(clsDiv).mCustomScrollbar({
			scrollButtons:{
				enable:true
			}
		});
	}
	
	function scrollingHome(){
		var nav = $('.nav-menu');
		var hometop = $('.top-control');
		var container_nav = $('.navigation-container');
		var colorbox = $('.box-color');
	    $(window).scroll(function () {
	        if ($(this).scrollTop() > $('.banner').height()) {
	            nav.addClass("fixed");
	            hometop.addClass("fixed");
	            container_nav.addClass("fixed");
	            colorbox.addClass("fixed");
	            //SiteMain.detectFixedMenu();
	        } else {
	            nav.removeClass("fixed");
	            hometop.removeClass("fixed");
	            container_nav.removeClass("fixed");
	            colorbox.removeClass("fixed");
	            //SiteMain.detectFixedMenu();
	        }
	    });
	}
	
	return {
		init:init
	}
})();	
